/*     */ package com.yc.dao;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.MagnifierBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class MagnifierDAO
/*     */ {
/*  21 */   private static final Log log = LogFactory.getLog(MagnifierDAO.class);
/*     */ 
/*  23 */   private dbConnector dbcon = null;
/*  24 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*  25 */   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  28 */     if (this.dbcon == null)
/*  29 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  33 */     if (this.dbcon != null)
/*  34 */       this.dbcon.closeAll();
/*  35 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getMagnifierList(Map condition)
/*     */   {
/*  41 */     ListContentsBFO bfo = new ListContentsBFO();
/*  42 */     int start = Integer.parseInt(condition.get("start").toString());
/*  43 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  44 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  45 */     ResultSet rs = null;
/*  46 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  49 */       dbConInit();
/*  50 */       String strSQL = " select count(id) from magnifier where btscode = '" + strBtscode + "' ";
/*  51 */       log.info(strSQL);
/*  52 */       rs = this.dbcon.execQuery(strSQL);
/*  53 */       if (rs.next()) {
/*  54 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  56 */       strSQL = " select * from magnifier where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  57 */       log.info(strSQL);
/*  58 */       rs = this.dbcon.execQuery(strSQL);
/*  59 */       while (rs.next()) {
/*  60 */         MagnifierBO bo = new MagnifierBO();
/*  61 */         bo.setId(rs.getString("id"));
/*  62 */         bo.setBtscode(rs.getString("btscode"));
/*  63 */         bo.setBtsname(rs.getString("btsname"));
/*  64 */         bo.setType(rs.getString("type"));
/*  65 */         bo.setCapacity(rs.getString("capacity"));
/*  66 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  67 */         bo.setNum(rs.getString("num"));
/*  68 */         bo.setCellU(rs.getString("cellU"));
/*  69 */         bo.setOpentime(rs.getDate("opentime"));
/*  70 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  71 */         bo.setMaintenance(rs.getString("maintenance"));
/*  72 */         bo.setMemo(rs.getString("memo"));
/*  73 */         list.add(bo);
/*     */       }
/*  75 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  78 */       e.printStackTrace();
/*  79 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  82 */       dbConClose();
/*     */     }
/*  84 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveMagnifier(MagnifierBO bo)
/*     */   {
/*  89 */     log.info("添加--塔放---开始");
/*  90 */     boolean flag = true;
/*     */     try
/*     */     {
/*  93 */       dbConInit();
/*  94 */       StringBuffer sqlBuf = new StringBuffer();
/*  95 */       sqlBuf.append(" insert into magnifier ( btscode,btsname, type, capacity, manufacturer, num,");
/*  96 */       sqlBuf.append("  cellU, opentime, maintenance, refreshtime,registtime, memo) values ( ");
/*  97 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/*  98 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/*  99 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 100 */       sqlBuf.append(" '" + bo.getCapacity() + "' ,");
/* 101 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 102 */       sqlBuf.append(" '" + bo.getNum() + "' ,");
/* 103 */       sqlBuf.append(" '" + bo.getCellU() + "' ,");
/* 104 */       sqlBuf.append(" '" + this.sdf.format(bo.getOpentime()) + "' ,");
/* 105 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 106 */       sqlBuf.append(" '" + this.sdf.format(new Date()) + "' ,");
/* 107 */       sqlBuf.append(" '" + this.open.format(new Date()) + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getMemo() + "' )");
/* 109 */       log.info(sqlBuf.toString());
/* 110 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 114 */       flag = false;
/* 115 */       e.printStackTrace();
/* 116 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 119 */       dbConClose();
/*     */     }
/* 121 */     log.info("添加--塔放---结束");
/* 122 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateMagnifier(MagnifierBO bo)
/*     */   {
/* 127 */     log.info("修改--塔放---开始");
/* 128 */     boolean flag = true;
/*     */     try
/*     */     {
/* 131 */       dbConInit();
/* 132 */       StringBuffer sqlBuf = new StringBuffer();
/* 133 */       sqlBuf.append(" update magnifier set ");
/* 134 */       sqlBuf.append(" btscode = '" + bo.getBtscode() + "' ,");
/* 135 */       sqlBuf.append(" btsname = '" + bo.getBtsname() + "' ,");
/* 136 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 137 */       sqlBuf.append(" capacity = '" + bo.getCapacity() + "' ,");
/* 138 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 139 */       sqlBuf.append(" num = '" + bo.getNum() + "' ,");
/* 140 */       sqlBuf.append(" cellU = '" + bo.getCellU() + "' ,");
/* 141 */       sqlBuf.append(" opentime = '" + this.sdf.format(bo.getOpentime()) + "' ,");
/* 142 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 143 */       sqlBuf.append(" refreshtime = '" + this.sdf.format(new Date()) + "' ,");
/* 144 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ");
/* 145 */       sqlBuf.append(" where id = '" + bo.getId() + "' ");
/* 146 */       log.info(sqlBuf.toString());
/* 147 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 151 */       flag = false;
/* 152 */       e.printStackTrace();
/* 153 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 156 */       dbConClose();
/*     */     }
/* 158 */     log.info("修改--塔放---结束");
/* 159 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteMagnifier(String strID)
/*     */   {
/* 165 */     log.info("删除--塔放---开始");
/* 166 */     boolean flag = true;
/*     */     try
/*     */     {
/* 169 */       dbConInit();
/* 170 */       StringBuffer sqlBuf = new StringBuffer();
/* 171 */       sqlBuf.append(" delete from magnifier   ");
/* 172 */       sqlBuf.append(" where id = '" + strID + "' ");
/* 173 */       log.info(sqlBuf.toString());
/* 174 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 178 */       flag = false;
/* 179 */       e.printStackTrace();
/* 180 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 183 */       dbConClose();
/*     */     }
/* 185 */     log.info("删除--塔放---结束");
/* 186 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getMagnifierByBtsName(Map condition)
/*     */   {
/* 191 */     ListContentsBFO bfo = new ListContentsBFO();
/* 192 */     int start = Integer.parseInt(condition.get("start").toString());
/* 193 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 194 */     String strBtsName = condition.get("btsName").toString();
/* 195 */     ResultSet rs = null;
/* 196 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 199 */       dbConInit();
/* 200 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 201 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 203 */       String strSQL = " select count(id) from magnifier where btsname like '%" + strBtsName + "%' ";
/* 204 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 205 */       log.info(strSQL);
/* 206 */       rs = this.dbcon.execQuery(strSQL);
/* 207 */       if (rs.next()) {
/* 208 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 210 */       strSQL = " select * from magnifier where btsname like '%" + strBtsName + "%' ";
/* 211 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 212 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 213 */       log.info(strSQL);
/* 214 */       rs = this.dbcon.execQuery(strSQL);
/* 215 */       while (rs.next()) {
/* 216 */         MagnifierBO bo = new MagnifierBO();
/* 217 */         bo.setId(rs.getString("id"));
/* 218 */         bo.setBtscode(rs.getString("btscode"));
/* 219 */         bo.setBtsname(rs.getString("btsname"));
/* 220 */         bo.setType(rs.getString("type"));
/* 221 */         bo.setCapacity(rs.getString("capacity"));
/* 222 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 223 */         bo.setNum(rs.getString("num"));
/* 224 */         bo.setCellU(rs.getString("cellU"));
/* 225 */         bo.setOpentime(rs.getDate("opentime"));
/* 226 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 227 */         bo.setMaintenance(rs.getString("maintenance"));
/* 228 */         bo.setMemo(rs.getString("memo"));
/* 229 */         list.add(bo);
/*     */       }
/* 231 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 234 */       e.printStackTrace();
/* 235 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 238 */       dbConClose();
/*     */     }
/* 240 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName)
/*     */   {
/* 245 */     ResultSet rs = null;
/* 246 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 249 */       dbConInit();
/* 250 */       String strSQL = " select * from magnifier where btsname like '%" + strBtsName + "%' ";
/* 251 */       log.info(strSQL);
/* 252 */       rs = this.dbcon.execQuery(strSQL);
/* 253 */       while (rs.next()) {
/* 254 */         MagnifierBO bo = new MagnifierBO();
/* 255 */         bo.setId(rs.getString("id"));
/* 256 */         bo.setBtscode(rs.getString("btscode"));
/* 257 */         bo.setBtsname(rs.getString("btsname"));
/* 258 */         bo.setType(rs.getString("type"));
/* 259 */         bo.setCapacity(rs.getString("capacity"));
/* 260 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 261 */         bo.setNum(rs.getString("num"));
/* 262 */         bo.setCellU(rs.getString("cellU"));
/* 263 */         bo.setOpentime(rs.getDate("opentime"));
/* 264 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 265 */         bo.setMaintenance(rs.getString("maintenance"));
/* 266 */         bo.setMemo(rs.getString("memo"));
/* 267 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 271 */       e.printStackTrace();
/* 272 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 275 */       dbConClose();
/*     */     }
/* 277 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.MagnifierDAO
 * JD-Core Version:    0.6.2
 */